import request from '@/axios'
import { toRaw } from '@vue/reactivity'

/**
 * 
 * Admin
 * 
 */

export const getCategoryListApi = (params) => {
  return request.post({ url: '/category/list' , params: params })
}

export const deleteCategoryListApi = (id) => {
  return request.delete({ url: '/category/delete', params: { "id": id } })
}

export const saveCategoryInfoApi = (params) => {
  return request.post({ url: '/category/save' , data: toRaw(params) })
}


/**
 * 
 * Web
 * 
 */

// 获取分类id的数据
export const getTopCategoryAPI = (id) => {
  return request.get({ url: '/category', params: { id } })
}

// 分类数据获取
export const getBannerAPI = (params = {}) => {
  // 默认为1 商品为2
  const { distributionSite = '1' } = params
  return request.get({ url: '/home/banner', params: { distributionSite } })
}

// 二级分类数据获取
export const getSubCategoryAPI = (id) => {
  return request.get({ url: '/category/sub/filter', params: { id } })
}

// 分类基础列表数据获取
export const getSubCategoryListAPI = (data) => {
  return request.post({ url: '/category/goods/temporary', data })
}
